* {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb-color) var(--scroll-track-color);
}

.admin-banner {
  background-color: var(--admin-banner-bg) !important;
  color: var(--admin-banner-text) !important;
  font-size: 14px;
  margin-top: 22px !important;
  margin-bottom: 0;
  padding: 0.5rem 0.7rem;

  strong {
    color: inherit;
  }

  .btn-warning {
    background-color: var(--admin-banner-btn-bg);
    color: var(--admin-banner-btn-text) !important;

    &:hover {
      background-color: var(--admin-banner-btn-hover-bg);
    }

    &:active {
      background-color: var(--admin-banner-btn-active-bg) !important;
    }
  }
}

.wiki-page-meta {
  font-size: $font-size-sm;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: auto;
  width: 100%;
  max-width: 650px;
}

.drafts {
  border: 1px solid var(--searchbar-color) !important;
  border-radius: 0.5rem;

  .table th,
  .table td {
    border-top: 1px solid var(--table-border-color);
  }
}

.dropdown-menu {
  background-color: var(--editor-background-color);
  border-color: var(--editor-background-color);

  .dropdown-item {
    color: var(--text-color);

    &:active,
    &:hover {
      background-color: var(--sidebar-hover-color);
      color: var(--text-color);
    }
  }
}

.nav-item {
  .dropdown-menu.show {
    top: 40px !important;
  }
}

.main-column {
  background-color: var(--background-color);
  padding: 0px 50px;
  width: 100%;

  @include media-breakpoint-down(md) {
    padding: 20px;
    width: 100vw;
  }
}

.wiki-editor {
  .wiki-title-container {
    margin-bottom: 1rem;
  }
  .wiki-title-input {
    color: var(--text-color);
    background-color: var(--editor-background-color);
  }
}

.feather-link {
  visibility: hidden;
}

.user-contributions {
  margin: 0 0 0 auto;
  color: var(--sidebar-text-color);
  font-size: 0.8rem;
}

.form-control:focus {
  color: var(--text-color);
  border: 1px solid var(--gray-500);
}

.contributions-header {
  margin: 2rem 0 1.5rem 0;
  font-size: $font-size-xl;
  font-weight: 700;
  line-height: 16px;
}

.count {
  font-size: var(--text-xs);
  background-color: var(--gray-700);
  border-radius: var(--border-radius-sm);
  color: var(--gray-50);
  padding: 0 var(--padding-xs);
  float: right;
  margin-top: 2px;
}

img::after {
  content: "";
}

img[alt]::after {
  width: unset;
  height: unset;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--text-color) !important;
  font-weight: 600 !important;
}

strong {
  font-weight: 800 !important;
}

h1 {
  margin-top: 3rem;
  margin-bottom: 0.75rem;
  font-size: 30px;
  font-weight: 600;
  line-height: 28px;
  letter-spacing: 0.005em;

  @include media-breakpoint-up(sm) {
    margin-top: 1.5rem !important;
    margin-bottom: 0 !important;
  }
}

h2 {
  font-size: 22px;
  margin-top: 2rem;
  margin-bottom: 0.5rem;

  @include media-breakpoint-up(sm) {
    margin-top: 4rem;
    margin-bottom: 0.75rem;
  }
}

h3 {
  font-size: 20px;
  margin-top: 2rem;
  margin-bottom: 0.5rem;

  @include media-breakpoint-up(sm) {
    margin-top: 2.5rem;
  }
}

h4 {
  font-size: 18px;
  margin-top: 2rem;
  margin-bottom: 0.5rem;

  @include media-breakpoint-up(sm) {
    margin-top: 2.5rem;
  }

  a {
    color: $body-color;
  }
}

h5 {
  font-size: 16px;
}

h6 {
  font-size: 16px;
}

p {
  font-size: 1rem;
}

.text-sm {
  font-size: 13px !important;
  line-height: 1.15;
  letter-spacing: 0.02em;
}

.text-xs {
  font-size: 12px;
  line-height: 1.15;
  letter-spacing: 0.02em;
  font-weight: 400;
}

.wiki-space-route-block {
  padding: 0.4rem 0.5rem;
  border-radius: 0.375rem;
  background-color: var(--bqoute-border-color);
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.wiki-editor,
.wiki-content {
  font-size: map-get($font-sizes-desktop, "base");
  line-height: 1.7;
  max-width: calc(100vw - 6rem);

  a:not(.dropdown-item, .btn) {
    color: var(--text-color);
    text-decoration: underline;
  }

  ul,
  ol {
    padding-left: 2rem;
  }

  ul {
    list-style-type: disc;
  }

  ol {
    list-style: decimal;
  }

  li {
    padding-top: 1px;
    padding-bottom: 1px;

    &::marker {
      color: var(--editor-button-text-color);
    }

    p {
      margin-bottom: 0;
    }
  }

  li > ul,
  li > ol {
    padding-left: 1.5rem;
  }

  ul > li:first-child {
    margin-top: 3px !important;
  }

  ul > * + *,
  ol > * + * {
    margin-top: 2px !important;
  }

  blockquote {
    padding: 0.75rem 1rem 0.75rem 1.25rem;
    font-size: $font-size-sm;
    font-weight: 500;
    border: 1px solid var(--bqoute-border-color);
    border-left: 5px solid var(--bqoute-border-color);
    border-radius: 0.5rem;
    margin: 1.5rem 0 !important;
    background-color: var(--bqoute-bg-color);
  }

  blockquote p:last-child {
    margin-bottom: 0 !important;
  }

  b,
  strong {
    color: var(--content-text-color);
    font-weight: 600;
  }

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    color: $gray-900;
  }

  h2,
  h3,
  h4,
  h5,
  h6 {
    font-weight: 600;
  }

  h1 {
    font-size: map-get($font-sizes-desktop, "3xl");
    line-height: 1.5;
    font-weight: 600;

    // for byline
    & + p {
      margin-top: 1rem !important;
      line-height: 1.4;
    }
  }

  & > p {
    margin-top: 1rem !important;
  }

  h2 {
    font-size: map-get($font-sizes-mobile, "2xl");
    line-height: 1.56;
    margin: 3rem 0 1rem !important;

    @include media-breakpoint-up(md) {
      font-size: map-get($font-sizes-desktop, "2xl");
    }
  }

  h3 {
    font-size: map-get($font-sizes-mobile, "xl");
    line-height: 1.56;
    margin: 2rem 0 1rem !important;

    @include media-breakpoint-up(md) {
      font-size: map-get($font-sizes-desktop, "xl");
    }
  }

  h4 {
    font-size: map-get($font-sizes-mobile, "lg");
    line-height: 1.56;
    margin-top: 1.25rem !important;
  }

  h5:not(.modal-title) {
    font-size: map-get($font-sizes-mobile, "base");
    line-height: 1.5;
    font-weight: 600;
    margin-top: 1rem !important;
  }

  h6 {
    font-size: map-get($font-sizes-mobile, "sm");
    line-height: 1.35;
    font-weight: 600;
    text-transform: uppercase;
    margin-top: 1rem !important;
  }

  tr > td,
  tr > th {
    font-size: $font-size-sm;
    padding: 0.5rem;
  }

  th:empty {
    display: none;
  }

  .screenshot {
    border: 1px solid $gray-400;
    border-radius: 0.375rem;
    margin-top: 0.5rem !important;
  }

  .screenshot + em {
    text-align: center;
    display: block;
    margin-top: 0.5rem !important;
    margin-bottom: 2rem !important;
  }

  p > code:not(.hljs) {
    padding: 0 0.25rem;
    background-color: var(--code-bg-color);
    color: var(--code-text-color);
    border-radius: 0.125rem;
  }

  table {
    border-color: $gray-200;
    border-collapse: collapse;
    table-layout: fixed;
    width: 100%;
    margin: 0;
    overflow: hidden;

    td,
    th {
      min-width: 1em;
      padding: 3px 5px;
      vertical-align: top;
      box-sizing: border-box;
      position: relative;

      > * {
        margin-bottom: 0;
      }
    }

    th {
      font-weight: bold;
      text-align: left;
      background-color: var(--table-header-color);
    }

    .selectedCell:after {
      z-index: 2;
      position: absolute;
      content: "";
      left: 0;
      right: 0;
      top: 0;
      bottom: 0;
      background: rgba(200, 200, 255, 0.4);
      pointer-events: none;
    }

    .column-resize-handle {
      position: absolute;
      right: -2px;
      top: 0;
      bottom: -2px;
      width: 4px;
      background-color: #adf;
      pointer-events: none;
    }

    p {
      margin: 0;
    }
  }

  .table-bordered,
  .table-bordered th,
  .table-bordered td {
    border: 1px solid;
    border-color: var(--table-border-color);
    color: inherit;
  }

  .table-bordered thead th,
  .table-bordered thead td {
    border-bottom-width: 1px;
  }

  pre {
    overflow: hidden;
    position: relative;

    &:hover .copy-btn {
      visibility: visible;
    }

    .copy-btn {
      visibility: hidden;
      right: 0.5rem;
      padding: 0.75rem;
      position: absolute;
      background-color: inherit;

      &:hover {
        color: var(--gray-500);
        background-color: inherit;
        border-color: inherit;
      }

      &:focus {
        box-shadow: none;
      }
    }

    // code {
    //   overflow-x: auto;
    //   color: inherit;
    //   background: none !important;

    //   del {
    //     &.diffmod,
    //     &.diffdel {
    //       background-color: #8b0000;
    //     }
    //   }

    //   // ins {
    //   //   &.diffmod,
    //   //   &.diffins {
    //   //     background-color: #006400;
    //   //   }
    //   // }
    // }
  }

  hr {
    border-top: 1px solid $gray-200;
  }
}

.wiki-editor {
  margin-left: -2rem;
  width: 800px;

  .ace_print-margin {
    visibility: hidden !important;
  }

  @include media-breakpoint-down(md) {
    margin: 0;
    width: 100%;
    max-width: none;
  }

  pre {
    padding: 0.75rem 1rem;
  }

  h1 {
    font-size: map-get($font-sizes-desktop, "3xl");
    line-height: 1.5;
    font-weight: 600;

    // for byline
    & + p {
      margin-top: 1rem !important;
      line-height: 1.4;
    }
  }

  & > p {
    margin-top: 1rem !important;
  }

  h2 {
    font-size: map-get($font-sizes-mobile, "2xl");
    line-height: 1.56;
    margin: 3rem 0 1rem !important;

    @include media-breakpoint-up(md) {
      font-size: map-get($font-sizes-desktop, "2xl");
    }
  }

  h3 {
    font-size: map-get($font-sizes-mobile, "xl");
    line-height: 1.56;
    margin: 2rem 0 1rem !important;

    @include media-breakpoint-up(md) {
      font-size: map-get($font-sizes-desktop, "xl");
    }
  }

  h4 {
    font-size: map-get($font-sizes-mobile, "lg");
    line-height: 1.56;
    margin-top: 1.25rem !important;
  }

  h5:not(.modal-title) {
    font-size: map-get($font-sizes-mobile, "base");
    line-height: 1.5;
    font-weight: 600;
    margin-top: 1rem !important;
  }

  h6 {
    font-size: map-get($font-sizes-mobile, "sm");
    line-height: 1.35;
    font-weight: 600;
    text-transform: uppercase;
    margin-top: 1rem !important;
  }

  p {
    font-size: 15px;
    font-weight: 420;
    line-height: 155%;
    letter-spacing: 0.02em;
    text-align: left;
  }

  button:not(.btn-primary) {
    all: unset;
    cursor: pointer;
    background: var(--editor-background-color);
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
  }

  .btn-primary {
    color: var(--btn-primary-color) !important;
    background-color: var(--btn-primary-bg-color) !important;
  }

  .btn-primary:hover {
    background-color: var(--btn-primary-hover-bg-color) !important;
  }

  .btn-primary:active {
    color: var(--btn-primary-color) !important;
    background-color: var(--btn-primary-active-bg-color) !important;
  }

  .btn-secondary {
    color: var(--btn-secondary-color) !important;
    background-color: var(--btn-secondary-bg-color) !important;
  }

  .btn-secondary:hover {
    background-color: var(--btn-secondary-hover-bg-color) !important;
  }

  .btn-secondary:active {
    background-color: var(--btn-secondary-active-bg-color) !important;
  }

  a.btn-primary-light {
    background-color: var(--btn-secondary-color) !important;
  }

  button:hover {
    background-color: var(--editor-hover-button-color);
  }

  .is-active {
    background-color: var(--editor-hover-button-color) !important;
  }

  .dropdown {
    display: inline-block;

    #dropdownMenuButton::after {
      display: none;
    }
  }

  .dropdown-menu.show {
    transform: translate3d(1px, 28px, 0px) !important;
  }

  .ace_editor {
    height: 70vh;
    padding: 0 1rem;
    padding-right: 120px;
    border-radius: 0.5rem;
    background-color: var(--editor-background-color);

    @include media-breakpoint-down(md) {
      padding-right: 1rem;
      width: 92vw;
    }

    .is-empty::before {
      content: attr(data-placeholder);
      float: left;
      color: #ced4da;
      pointer-events: none;
      height: 0;
    }

    &:focus-visible {
      outline: none;
    }
  }
  .ace_editor .ace_gutter {
    z-index: auto;
    background: var(--editor-background-color);
    color: var(--text-light);
  }

  img.ProseMirror-selectednode {
    border: 2px solid #7cbcf5;
  }

  > :last-child {
    overflow-x: auto;
    margin-top: 0 !important;
    border-radius: 0.5rem;
  }

  > :first-child {
    padding-bottom: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 800px;

    @include media-breakpoint-down(md) {
      width: 100%;
      flex-wrap: nowrap;
      align-items: flex-start;
    }

    .wiki-edit-controls {
      flex-wrap: wrap;
      display: inline-flex;
      row-gap: 0.5rem;
    }

    .wiki-edit-control-btn {
      margin-left: auto;
      display: inline-flex;

      > * {
        margin: 0.5rem 0.25rem;
      }

      @include media-breakpoint-down(md) {
        margin-left: 0;
        align-items: flex-start;
      }
    }
  }
}

.wiki-content {
  min-height: 55vh;

  @include media-breakpoint-down(md) {
    max-width: calc(100vw - 3rem);
  }

  div > p:first-child {
    margin-top: 1.5rem !important;
    line-height: 1.4;
  }

  code {
    padding: 0.75rem 1rem;
  }

  // tiptap task-list
  ul[data-type="taskList"] p {
    margin: 0 !important;
  }
}

.btn:hover {
  color: #000;
  background-color: #f9fafb;
  border-color: #f9fafb;
}

.btn.btn-primary:hover {
  color: #fff;
  background-color: var(--button-background-color);
  border-color: #383838;
}

// tiptap task-list
ul[data-type="taskList"] {
  list-style: none;
  padding: 0;

  p {
    margin: 0;
  }

  li {
    display: flex;

    > label {
      flex: 0 0 auto;
      margin-right: 0.25rem;
      margin-bottom: 0;
      user-select: none;
    }

    > div {
      flex: 1 1 auto;
    }

    ul li,
    ol li {
      display: list-item;
    }

    ul[data-type="taskList"] > li {
      display: flex;
    }

    input {
      color: #000;
      margin: 0.1rem;
      margin-top: 0.4rem;
      border: 1px solid var(--gray-500);
      accent-color: black;

      &:checked {
        background-color: var(--primary);
        background-image: url("data:image/svg+xml, <svg viewBox='0 0 8 7' fill='none' xmlns='http://www.w3.org/2000/svg'><path d='M1 4.00001L2.66667 5.80001L7 1.20001' stroke='white' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>"),
          var(--checkbox-gradient);
        background-size: 57%, 100%;
        box-shadow: none;
        border: none;
      }
    }
  }
}

.file-upload-area {
  background: var(--btn-secondary-bg-color) !important;
}

.file-upload-area div button {
  color: var(--btn-secondary-color) !important;
}

.ace_editor .ace_marker-layer .ace_selection {
  background: var(--editor-text-selection-color) !important;
}

.toolbar {
  padding-bottom: 8px;
  display: flex;
  gap: 6px;
}

.toolbar button {
  width: 26px !important;
  height: 26px !important;
  background: var(--editor-toolbar-btn-bg-color) !important;
  border: 1px solid #ccc;
  border-radius: 4px !important;
  color: var(--editor-toolbar-btn-color) !important;
  cursor: pointer;
  padding: 2px !important ;

  svg {
    width: 18px;
    height: 18px;
  }
}

.toolbar i {
  font-size: 14px;
}

.no-revision {
  text-align: center;
  margin: 10px !important;
  font-size: 24px;
}

.forward-back {
  a {
    p {
      text-overflow: ellipsis;
      overflow: hidden;
      white-space: nowrap;
    }
  }
}

.btn.btn-secondary {
  color: var(--btn-secondary-color) !important;
  background-color: var(--btn-secondary-bg-color) !important;
}

.btn.btn-secondary:hover {
  background-color: var(--btn-secondary-hover-bg-color) !important;
}

.btn.btn-secondary:active {
  background-color: var(--btn-secondary-active-bg-color) !important;
}

.feedback-btn {
  cursor: pointer;

  &:hover {
    text-decoration: underline;
  }
}

.form-control {
  background-color: white;
  border: 1px solid var(--background-color);
}

@keyframes pulse {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
  100% {
    opacity: 1;
  }
}

.pulse {
  animation: pulse 1.5s infinite;
}
